<template>
  <el-dialog title="编辑分类" :visible.sync="isShow" width="30%" @close="close">
    <el-form :model="model" :rules="rules">
      <el-form-item label="分类名称：" :label-width="'100px'">
        <el-input v-model="model.courseCateName" autocomplete="on" placeholder="请输入章节名称"></el-input>
      </el-form-item>
      <el-form-item label="分类图标：" :label-width="'100px'">
        <el-upload
          class="avatar-uploader"
          action="https://jsonplaceholder.typicode.com/posts/"
          :show-file-list="false"
        >
          <img v-if="model.cateIcon" :src="model.cateIcon" class="avatar">
          <i v-else class="el-icon-plus avatar-uploader-icon"></i>
        </el-upload>
      </el-form-item>
    </el-form>
    <div slot="footer" class="dialog-footer">
      <el-button @click="close">{{$t('action.cancel')}}</el-button>
      <el-button type="primary" @click="close(model)">{{$t('action.comfirm')}}</el-button>
    </div>
  </el-dialog>
</template>

<script>
  export default {
    name: "AddCourseCate",
    props:["model"],
    created() {
      console.log(this)
    },
    data() {
      return {
        isShow:true,
        rules: {
          courseCateName: [
            {required: true, message: '请输入分类名称', trigger: 'blur'},
          ],
          cateIcon: [
            {required: true, message: '请选择分类图标', trigger: 'blur'},
          ],
        },
      }
    },
    methods:{
      close(data){
        this.$emit("closePop",data)
      }
    },
  }
</script>

<style scoped>

</style>
